
import React from 'react';
import { inject, observer } from 'mobx-react';
import { Icon, List, Tools } from 'weaver-mobile';
import { toJS } from 'mobx'
import { Link, withRouter, Route } from 'react-router-dom';
import './style/index.less'

const Item = List.Item;
const getLabel = Tools.getLabel;
@inject("wfMonitorStore")
@withRouter
@observer
export default class WfNoPermission extends React.Component {
    constructor(props) {
        super(props);
    }
    componentDidMount() {
        const { params = {}, wfMonitorStore } = this.props;
        const { setState } = wfMonitorStore;
        if (JSON.stringify(params) !== "{}") {
            Tools.callApi({
                url: '/workflow/search/WorkflowUnoperatorPersons.jsp',
                method: 'POST',
                type: "text",
                params: { requestid: params.requestid },
            }).then(data => {
                let new_params = {};
                new_params.requestid = params.requestid;
                new_params.requestname = params.requestname;
                new_params.workflowpath = params.workflowidspan;
                new_params.creator = params.createrspan;
                new_params.createtime = params.createdatespan;
                new_params.nowNode = params.currentnodeidspan;
                new_params.nowState = params.statusspan;
                new_params.noOperator = data.trim().replace(/\,/g, " ");
                setState({ noOpenRightParams: { ...new_params } });
            });
        }
    }

    getLi = () => {
        const { noOpenRightParams } = this.props.wfMonitorStore;
        const {
            requestid = "",
            requestidlabel = getLabel(125038, "流程ID"),
            requestname = "",
            requestnamelabel = getLabel(388770, "流程标题"),
            workflowpath = "",
            workflowpathlabel = getLabel(125749, "所属路径"),
            creator = "",
            creatorlabel = getLabel(882, "创建人"),
            createtime = "",
            createtimelabel = getLabel(30436, "创建时间"),
            nowNode = "",
            nowNodelabel = getLabel(501782, "当前节点"),
            nowState = "",
            nowStatelabel = getLabel(501786, "当前状况"),
            noOperator = "",
            noOperatorlabel = getLabel(501787, "当前未操作者")
        } = noOpenRightParams;
        return (
            <ul className='ul'>

                <li>
                    <div className="wf-no-permission-label">{requestidlabel}</div>
                    <div className="wf-no-permission-value">{requestid}</div>
                </li>
                <li>
                    <div className="wf-no-permission-label">{requestnamelabel}</div>
                    <div className="wf-no-permission-value">{requestname}</div>
                </li>
                <li>
                    <div className="wf-no-permission-label">{workflowpathlabel}</div>
                    <div className="wf-no-permission-value">{workflowpath}</div>
                </li>
                <li>
                    <div className="wf-no-permission-label">{creatorlabel}</div>
                    <div className="wf-no-permission-value">{creator}</div>
                </li>
                <li>
                    <div className="wf-no-permission-label">{createtimelabel}</div>
                    <div className="wf-no-permission-value">{createtime}</div>
                </li>
                <li>
                    <div className="wf-no-permission-label">{nowNodelabel}</div>
                    <div className="wf-no-permission-value">{nowNode}</div>
                </li>
                <li>
                    <div className="wf-no-permission-label">{nowStatelabel}</div>
                    <div className="wf-no-permission-value">{nowState}</div>
                </li>
                <li>
                    <div className="wf-no-permission-label">{noOperatorlabel}</div>
                    <div className="wf-no-permission-value limit-line-3">{noOperator}</div>
                </li>
            </ul>
        )
    }

    render() {
        return (
            <div className='wf-monitor-no-permission'>
                <div className='render-header'>您无权限查看流程表单，当前显示流程信息</div>
                {this.getLi()}
            </div>
        )
    }
}
